package com.xyzboom.compiler.compiler.grammar

import com.xyzboom.compiler.NoArg

/**
 * Terminator
 *
 * @property tokenName
 * @constructor Create empty Terminator
 */
@NoArg
class Terminator(val tokenName: String) : ISymbol {
    override val isTerminator: Boolean = true
    override fun simpleString(): String = tokenName

    companion object {
        val EOF = Terminator("#")
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (other !is Terminator) return false

        if (tokenName != other.tokenName) return false

        return true
    }

    override fun hashCode(): Int {
        return tokenName.hashCode()
    }

    override fun toString(): String {
        return "Terminator($tokenName)"
    }
}